
PROJECT_NAME=ddcglut

SRC=$(wildcard src/*.c)
OBJ=${SRC:src/%.c=src/%.o}
HEADERS=$(wildcard include/*.h)
COMPILER_FLAGS=-Wall -Werror -Wpedantic
STATIC_OUT=lib${PROJECT_NAME}.a

PREFIX=/usr

# create library
${STATIC_OUT}: ${OBJ}
	ar rcs $@ $^

# compile source files to object files
%.o: %.c ${HEADERS}
	${CC} ${COMPILER_FLAGS} -Iinclude -DDD_PLATFORM_NATIVE -o $@ -c ${@:%.o=%.c}

# install library
install: ${STATIC_OUT}
	mkdir -p ${PREFIX}/include
	install -m644 ${HEADERS} ${PREFIX}/include
	mkdir -p ${PREFIX}/lib
	install -m755 ${STATIC_OUT} ${PREFIX}/lib
